<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">
      <h:head>  
            <title>Sistema Integrado de Administracion Eco</title>
            <link href="resources/css/login.css" rel="stylesheet" type="text/css"/>
    </h:head>  
      
 <h:body>  
  <div class="container">
    <h:form id="frmlogin">
    <p:growl id="growl" showDetail="true" life="3000" />
        <p:panel header="Acceso al Sistema">
          <h:panelGrid columns="2" cellpadding="5">
            <h:outputLabel for="username" value="Usuario:" />
            <p:inputText value="#{loginBean.username}"
                    id="username" required="true" label="username" />
             
            <h:outputLabel for="password" value="Contraseña:" />
            <p:password value="#{loginBean.password}"
                    id="password" required="true" label="password"/>
            <f:facet name="footer">
                <p:commandButton id="loginButton" value="Login" update="growl"
                    actionListener="#{loginBean.login}"
                    oncomplete="handleLoginRequest(xhr, status, args)"/>
             </f:facet>
            </h:panelGrid>
        </p:panel>
    </h:form>      
  </div> 
        <script type="text/javascript">
            function handleLoginRequest(xhr, status, args) {
                if(args.validationFailed || !args.loggedIn) {
                    PF('dlg').jq.effect("shake", { times:5 }, 100);
                } 
                else {
                    PF('dlg').hide();
                    $('#loginLink').fadeOut();
                }
            }
        </script>
                
</h:body> 
</html>

